//
//  BookingHotelRoomHeadView.swift
//  DLuxTravel
//
//  Created by 陆涛 on 2018/12/3.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

class BookingHotelRoomHeadView: UITableViewHeaderFooterView {

    var roomLabel:UILabel!
    var adultLabel:UILabel!
    var childLabel:UILabel!
    
    var selectRoomAction:(()->Void)?
    
    override init(reuseIdentifier: String?) {
        
        super.init(reuseIdentifier: reuseIdentifier)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        
        super.init(coder: aDecoder)
    }
    
    private func setupUI() {
        
        self.backgroundView = UIView(frame: self.bounds)
        self.backgroundView?.backgroundColor = UIColor.white
        
        let width = (CGFloat(kScreenWidth) - 2) / 3
        let height:CGFloat = 40
        
        roomLabel = UILabel(frame: CGRect(x: 0, y: 0, width: width, height: height))
        roomLabel.textColor = kContentColor
        roomLabel.font = kFont12
        roomLabel.textAlignment = .center
        self.addSubview(roomLabel)
        
        let lineView1 = UIView(frame: CGRect(x: width, y: 5, width: 1, height: height - 10))
        lineView1.backgroundColor = kBgColor
        self.addSubview(lineView1)
        
        adultLabel = UILabel(frame: CGRect(x: width+1, y: 0, width: width, height: height))
        adultLabel.textColor = kContentColor
        adultLabel.font = kFont12
        adultLabel.textAlignment = .center
        self.addSubview(adultLabel)
        
        let lineView2 = UIView(frame: CGRect(x: width * 2 + 1, y: 5, width: 1, height: height - 10))
        lineView2.backgroundColor = kBgColor
        self.addSubview(lineView2)
        
        childLabel = UILabel(frame: CGRect(x: (width+1) * 2, y: 0, width: width, height: height))
        childLabel.textColor = kContentColor
        childLabel.font = kFont12
        childLabel.textAlignment = .center
        self.addSubview(childLabel)
        
        roomLabel.text = "房间数"
        adultLabel.text = "成人数"
        childLabel.text = "儿童数"
        
        
        roomLabel.isUserInteractionEnabled = true
        
        roomLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(roomAction)))
    }
    
    @objc private func roomAction() {
        
        selectRoomAction?()
    }
}
